package com.wildlife.springboot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/uploads/**")
                .addResourceLocations("file:/D:/Program Files (x86)/IdeaProjects/Wildlife/uploads/");
        // 配置静态资源映射
        registry.addResourceHandler("/videos/**")
                .addResourceLocations("file:/D:/Program Files (x86)/IdeaProjects/Wildlife/videos/");
        // 映射音频文件路径
        registry.addResourceHandler("/sounds/**")
                .addResourceLocations("file:D:/Program Files(x86)/IdeaProjects/Wildlife/sounds/");
        registry.addResourceHandler("/molecularSequences/**")
                .addResourceLocations("file:D:/Program Files(x86)/IdeaProjects/Wildlife/molecularSequences/");
    }
//
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")
////                .allowedOrigins("http://localhost:8080")
//                .allowedOriginPatterns("*")
////                .allowedOrigins("http://localhost:80")
//                .allowedMethods("GET", "POST", "PUT", "DELETE")
//                .allowedHeaders("*");
//    }

}
